General Solution Distance to a Line

Orthogonal Lines.png
Orthogonal Lines. The red line containing point $P$ is known. If the line is in some other form, then point $P$ is any point on the line and can be computed. Point $C(h,k)$ is also known and we wish to calculate the distance from $C$ to $E$ where $E$ is the intersection of the lines that forms a perpendicular angle. As shown, the equation for the blue line is written using the same slope $m$ that is the slope for the red line. The given line (red) has $y$-intercept, $b_{1}$.

First it has to be said that by distance from any point to any line, I am speaking only about 2-dimensions and the shortest or perpendicular distance. So, let's start with line $$y=mx+b_{1} \tag{EQ 1} \label{EQ 1}$$ (the red line containing point $P$ in figure Orthogonal-Lines) and point $C(h,k)$, which is not on the line. We will change to the perpendicular slope, $(-1/m)$ and use $(h,k)$ to write the perpendicular line. In point slope form, it is $$y-k=\left(\frac{-1}{m}\right)\left(x-h\right). \tag{EQ 2} \label{EQ 2}$$ Equation $\eqref{EQ 1}$ is a line that passes through $(h,k)$ and is perpendicular to $y=mx+b_{1}$. Now we can solve the two simultaneous equations, $\eqref{EQ 1}$ and $\eqref{EQ 2}$ to find their intersection. These can be solved by hand quite easily to give point $E$. $$\begin{array}{cccc} x_{1}={\displaystyle \frac{mk-mb_{1}+h}{m^{2}+1}} & \quad & \quad & y_{1}={\displaystyle \frac{km^{2}+hm+b_{1}}{m^{2}+1}}\end{array} \tag{EQ 3} \label{EQ 3}$$ If equation $\eqref{EQ 1}$ had been given in point slope form, it would be $$y-P_{y}=m\left(x-P_{x}\right)$$ and its solutions would be $$x_{1}=\frac{P_{x}\;m^{2}-P_{y}\;m+h+k\;m}{m^{2}+1},\qquad y_{1}=\frac{-P_{x}\;m+P_{y}+h\;m+k\;m^{2}}{m^{2}+1}$$ The new point $E(x_{1,},y_{1})$ represents a point on the line $y=mx+b_{1}$ which is the closest point to $(h,k)$. The next step is to get the distance from $(h,k)$ to $(x_{1},y_{1})$. $$\text{distance from C to E}=\sqrt{\left(h-x_{1}\right)^{2}+\left(k-y_{1}\right)^{2}}$$ With more than a little algebra, this can be expressed as $$\text{distance from C to E}=\frac{\left\Vert hm+b_{1}-k\right\Vert }{\sqrt{m^{2}+1}} =\frac{\left\Vert hm-P_{x}m+P_{y}-k\right\Vert }{\sqrt{m^{2}+1}} \tag{EQ 4} \label{EQ 4}$$

Example: Find the two tangent lines to a circle from point $P(6,7)$ to the circle $(x-1)^{2}+(y-2)^{2}=1.5^{2}$.
Answer: The distance from the center of the circle $C(1,2)$ to a point of tangency will be orthogonal to the tangent line and have length $r=1.5$. From equation $\eqref{EQ 4}$ we can set $$r=\frac{\left\Vert hm-P_{x}m+P_{y}-k\right\Vert }{\sqrt{m^{2}+1}}$$ and fill in for all of the values except $m$. $$1.5=\frac{\left\Vert m-6m+7-2\right\Vert }{\sqrt{m^{2}+1}}.$$ Solving for $m$ we get $$m=\frac{\pm3\;\sqrt{191}+100}{91}$$ and the tangent lines are $$y-P_{y}=\pm m\left(x-P_{x}\right)$$ $$y-7=0.64(x-6)\qquad y-7=1.55(x-6)$$ Notice that these tangent line equations were obtained without finding the points of tangency.